package com.olddriver.crm.service.impl;


import com.olddriver.crm.domain.Compensation;
import com.olddriver.crm.mapper.CompensationDetailsMapper;
import com.olddriver.crm.mapper.CompensationMapper;
import com.olddriver.crm.mapper.PaidListMapper;
import com.olddriver.crm.page.PageResult;
import com.olddriver.crm.query.CompensationQueryObject;
import com.olddriver.crm.service.ICompensationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class CompensationServiceImpl implements ICompensationService {

    @Autowired
    private CompensationMapper compensationMapper;

    @Autowired
    private PaidListMapper paidListMapper;

    @Autowired
    private CompensationDetailsMapper detailsMapper;


    @Override
    public void deleteByPrimaryKey(Long id) {
        compensationMapper.deleteByPrimaryKey(id);

    }

    @Override
    public void insert(Compensation record) {
        compensationMapper.insert(record);
        //detailsMapper.insertSnToDetail(sn);

    }

    @Override
    public Compensation selectByPrimaryKey(Long id) {
        Compensation claim = compensationMapper.selectByPrimaryKey(id);
        return claim;
    }

    @Override
    public List<Compensation> selectAll() {
        List<Compensation> compensation = compensationMapper.selectAll();
        return compensation;
    }

    @Override
    public void updateByPrimaryKey(Compensation record) {
        compensationMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult query(CompensationQueryObject qo) {
        int total = compensationMapper.queryTotal(qo);
        if (total == 0) {
            return new PageResult(total, Collections.emptyList());
        }
        return new PageResult(total, compensationMapper.queryRows(qo));
    }

    @Override
    public Compensation getCompensationByAccId(Long id) {
        return compensationMapper.getCompensationByAccId(id);
    }

}




